#!/usr/bin/env python
# -*-coding:utf-8-*-
# File    : liyuqi.py
# Date    : 2021-01-27
# Author  : Tom.Lee

import random
import requests
requests.packages.urllib3.disable_warnings()

#通过调用兔展注册接口来判断是否注册
def isregister(phone):
    sess = requests.session()
    headers = { 'Referer': 'https://testpassport.rabbitpre.com/'}
    url = "https://bws.test.rabbitpre.com/api/verify/getRandomValidImg"
    sess.headers = headers
    params = {'forceImg': 'false'}
    resp = sess.get(url, verify=False, params=params)
    hcode = resp.json()["data"]["humanId"]

    surl = "https://testpassport.rabbitpre.com/api/sso/sendPhoneValidationCode"
    params = {'phone': phone, 'sendType': '1',
              'humanId': hcode, 'userFrom': '',
              'opfid': ''}
    resp = sess.get(surl, verify=False, params=params)
    if resp.json()["errorCode"] == "USER_EXIST":
        return False
    return True


num_prefix = ("133", "149", "153", "173", "177", "180", "181", "189", "190", "191", "193",
              "199", "130", "131", "132", "145", "155", "156", "166", "167", "171", "175",
              "176", "185", "186", "196", "134", "135", "136", "137", "138", "139", "144",
              "147", "148", "150", "151", "152", "157", "158", "159", "172", "178", "182",
              "183", "184", "187", "188", "195", "197", "198", "170", "174")


for pre in num_prefix:
    suffix = random.randint(1, 99999999)
    phone = "{}{:0>8}".format(pre,suffix)
    # phone = "%s%0.8d" % (pre,suffix)
    print(phone)

    # if isregister(phone):
    #     print("{}可用于注册".format(phone))
    # break


